<?php

namespace App\Http\Controllers;

use App\Admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class IndentController extends Controller
{
    /**
     * @api indent
     * @method get
     * @comment 获取订单数据
     * @return array
     */
    public function indent(){
        $data=DB::table('indent')->get();
        return ['code'=>200,'message'=>'查询成功','data'=>$data];
    }
    
    /**
     * @api theOrder
     * @mehtod get
     * @comment 提交订单
     * @param Request $request
     */
    public function theOrder(Request $request){
        $id=$request->price;
        echo $id;
//        return ['code'=>200,'message'=>'下单成功','data'=>$id];
    }

    public function login(Request $request){
        $username = $request->post('user');
        $password = $request->post('password');
        $data=Admin::where(['username'=>$username,'password'=>$password])->first();
        if ($data){
            $token = $data->token;
            return ['code'=>200,'message'=>'查询成功','data'=>$token];
        }else{
            return ['code'=>400,'message'=>'查询失败','data'=>''];
        }
        
    }

}
